package com.ruoyi.hr.service.impl.welfare.welfarecalculation;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.domain.welfare.welfarecalculationconfig.CcdBenefititem;
import com.ruoyi.hr.mapper.welfare.welfarecalculation.WelfareCalculationHistoryMapper;
import com.ruoyi.hr.mapper.welfare.welfarecalculationconfig.CcdBenefititemMapper;
import com.ruoyi.hr.service.welfare.welfarecalculation.WelfareCalculationHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class WelfareCalculationHistoryServiceImpl implements WelfareCalculationHistoryService {

    @Autowired
    WelfareCalculationHistoryMapper welfareCalculationHistoryMapper;

    @Autowired
    CcdBenefititemMapper ccdBenefititemMapper;

    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> getBenefitProcess() {
        return welfareCalculationHistoryMapper.getBenefitProcess();
    }


    @DataSource(value = DataSourceType.SLAVE)
    @Override
    public List<Map<String, Object>> findEmpWelfareHistoryData(String jsid, Map map, List<Authority> authorities, int isAdmin) {
        String name = map.get("name").toString();
        String badge = map.get("badge").toString();
        Map<String, Object> map1 = new HashMap<String, Object>();
        map1.put("jsid", jsid);
        //拼接动态SQL
        List<CcdBenefititem> ccdBenefititems = ccdBenefititemMapper.findAlls();
        map1.put("pro", ccdBenefititems);
        map1.put("name", name);
        map1.put("badge", badge);
        List<Map<String, Object>> list = welfareCalculationHistoryMapper.findEmpWelfareHistoryData(map1,authorities,isAdmin);
        return list;
    }
}
